def merit_text
    text=[]
    #剧情成就
    text[1]=[0,20,"冲出森林","初次离开寂静之森"]
    text[2]=[0,20,"人心难测","在莱尼克之墓中被训蛇士背叛"]
    text[3]=[0,20,"大仇得报","于姆伊森运河上击杀训蛇士"]
    text[4]=[0,30,"赏金学徒","消灭赏金首—魉拙计"]
    text[5]=[0,30,"水晶剑骸","拔出埋藏于往昔之园中的水晶剑残骸"]
    text[6]=[0,30,"人族叛徒","击败佣兵公会叛逃者黑王"]
    text[7]=[1,50,"永不复还","被全能教团烧死在火刑柱上"]
    text[8]=[0,30,"冲破死域","恢复力量后离开归亡死域"]
    text[9]=[0,30,"恐怖巨人","击杀受创的乌诺巨人"]
    text[10]=[0,40,"英雄领域","突破英雄境界"]
    text[11]=[0,30,"诅咒人形","消灭爱丽丝城堡中的爱丽丝人形"]
    text[12]=[0,30,"屠龙勇者","斩杀复活后的寒冬骨龙"]
    text[13]=[0,50,"复仇伊始","乘坐位面传送阵返回辉煌大陆"]
    text[14]=[0,20,"拜访沙王","拜访沙王克里瑟历斯"]
    text[15]=[0,30,"神器跳刀","在闪烁沙漠中获得闪烁匕首"]
    text[16]=[0,40,"斩灭圣光","在西北荒原击杀绝对正义神甫"]
    text[17]=[0,40,"传奇装备","获得传奇装备“飓风长戟”"]
    text[18]=[0,30,"最强九阶","于不朽山谷中消灭玛朵妮丝"]
    text[19]=[1,50,"逆斩传奇","击杀天辉传奇统军"]
    text[20]=[0,30,"天壤试炼","进入天壤之塔第24层。之后可以跳过该部分战斗区域"]
    text[21]=[0,30,"星界之旅","从星界平安回归"]
    text[22]=[0,40,"大世资格","获得参与大世的资格凭证"]
    text[23]=[0,30,"小试牛刀","大世中击败第一个少年王级别的对手"]
    text[24]=[0,30,"生命跃迁","在真理之要塞内完成生命跃迁"]
    text[25]=[0,40,"魂海初成","开创七重魂海替代传奇史诗境界"]
    #技巧成就
    text[101]=[0,25,"一滴不漏","在满血的状态下累计获取20枚生命上限宝石"]
    text[102]=[0,25,"移动血瓶","通过消灭敌人获得生命值累计超过2000点"]
    text[103]=[1,50,"一战到底","中途不回血，连续击败6个伤害超过当前生命33%的敌人"]
    text[104]=[2,120,"碾压的开始","Normal及以上难度运河处省下一把红钥匙"]
    text[105]=[1,100,"强者的力量","Hard难度无伤击败赏金首—魉拙计"]
    text[106]=[1,40,"以一敌多","砂锁之地地下密厅不开黄门消灭所有敌人"]
    text[107]=[1,50,"恶魔诱惑","在未购买过钥匙的前提下通过第二章"]
    text[108]=[1,120,"征服死亡","Hard难度满血状态下决战归亡死域入口的BOSS"]
    text[109]=[1,75,"吃你一击又如何","在不打断无敌斩的情况下击败恶魔骑士梅罗"]
    text[110]=[1,30,"粉碎石像","在进入暗影庇护所之前击杀过全部三种石像鬼"]
    text[111]=[1,40,"攻速为0！","在攻速为0的状态下击杀任意寒夜冰川的怪物"]
    text[112]=[1,50,"无影身法","在与炼的对决中完全躲开其所有攻击"]
    text[113]=[1,20,"智慧就是金钱","在未合成过迈达斯之手的情况下通关苍白之巢"]
    text[114]=[2,100,"人偶爱好者","Normal及以上难度不消灭同地图任何人偶并击败爱丽丝"]
    text[115]=[3,50,"拯救少女的人","不朽山谷特殊战中选择困难难度并通过"]
    text[116]=[1,50,"绝望挑战者","通过绝望之塔挑战模式的第三层"]
    text[117]=[2,50,"绝望征服者","通过绝望之塔挑战模式的第七层"]
    text[118]=[1,50,"初级法师","无伤击杀西北荒原的诅咒玛荷坎王"]
    text[119]=[2,80,"剧毒折磨","第五章全程不使用卫士胫甲的主动效果"]
    text[120]=[2,-500,"封弊者","进行过任何一次作弊模式下的游戏，扣除500成就点"]
    text[121]=[2,150,"天壤末日","通关天壤之塔挑战模式"]
    text[122]=[3,50,"无法拯救……","方界圣所特殊战中选择困难难度并通过"]
    text[123]=[2,40,"胜利突围","直接进入方界圣所内部后突围到外面"]
    text[124]=[1,40,"互相伤害","只凭借刃甲的伤害便在一回合内反弹死敌人"]
    text[125]=[1,20,"力量即觉悟","鲭海传承中不借助帮助通过考验"]
    text[126]=[2,80,"以命夺金","真理之要塞上层拿取至少八个远古赏金神符"]
    text[127]=[1,40,"全境封锁","身上拥有至少20层闭锁烙印效果"]
    text[128]=[3,50,"命运的相逢","远古殿堂特殊战中选择困难难度并通过"]
    #探索成就
    text[201]=[0,25,"勇气可嘉","选择传奇史诗难度并正式开始游戏"]
    text[202]=[0,20,"勤恳好学","调查过第一章所有教程路牌"]
    text[203]=[0,20,"原地传送","连续通过小站传送到原地三次"]
    text[204]=[0,25,"手持“神装”","装备未知法球累计击败10个敌人"]
    text[205]=[0,15,"错误选择","使用树枝交换了一把蓝钥匙"]
    text[206]=[0,30,"不可描述","触发结局“不可描述”"]
    text[207]=[0,15,"剧情错误","青铜职业者境界之前进入往昔之园"]
    text[208]=[0,50,"居然能找到这里","调查归亡死域某个不一样的坟墓"]
    text[209]=[0,20,"一除以二","1血时受到夹击魔法效果并因此死亡"]
    text[210]=[0,20,"炒鸡蛋木","调查爱丽丝城堡书架并发现小说"]
    text[211]=[0,30,"魂飞魄散","在灵魂不足的情况下受灵魂汲取效果导致死亡"]
    text[212]=[1,30,"不动如山","在与炼的对决中完全不闪避抗下所有攻击"]
    text[213]=[2,50,"开启锁子甲的人","顾名思义"]
    text[214]=[0,20,"失败的炼金","使用迈达斯之手炼化一个没有金币的敌人"]
    text[215]=[0,20,"天天摸鱼","连续在哈比脚趾酒吧使用金钱切换五次日夜"]
    text[216]=[0,25,"这和说好的不一样！","希尔芙侦查地带中死于切换地图后光环造成的伤害变化"]
    text[217]=[0,15,"射成筛子","在妖精之泉最上方地图连续受到强力击的攻击"]
    text[218]=[0,40,"毒素入体","毒素烙印BUFF叠加到30层以上"]
    text[219]=[0,25,"ZZXC","特殊战中按ZZXC的顺序使用影压命中连续三轮"]
    text[220]=[0,20,"王者的姿态","在领主王座的王座上，面朝下停留10秒以上"]
    text[221]=[0,20,"儿时的梦想","在领主王座中购买极限法球"]
    text[222]=[0,20,"隐身=无敌？","隐身状态下死于真视领域的效果"]
    text[223]=[0,20,"灰飞烟灭","鵐目山脉强冲异化要塞炮导致死亡"]
    text[224]=[0,20,"临阵脱逃","天壤之塔击败迪迪姆后试图逃离"]
    text[225]=[0,15,"要钱不要命","传奇附魔组合选择三层财富属性"]
    text[226]=[0,30,"出门被车撞","利用沟壑消灭真理之要塞中层的冶鸟形鸠"]
    text[227]=[0,20,"功力尽失","积累超过30层虚弱烙印导致攻防归零"]
    text[228]=[0,20,"你去找紫门要分吧","真理之要塞上层开启紫门后击败迪迦基"]
    text[229]=[0,25,"恭喜你全答对了","司存传承中给出某个特定答案组合然而失去资格"]
    return text
end
class Scene_Title #成就
  def merit
    bitmap=RPG::Cache.title("merit")
    @mindex1=$merit[301][3]
    @mindex2=$merit[301][@mindex1]
    text=merit_text
    
    @point=0
    for i in 1...301
      if text[i]!=nil && $merit[i][0]
        @point+=text[i][1]
      end
    end
    @point_text=Sprite.new
    @point_text.bitmap=Bitmap.new(120,80)
    @point_text.bitmap.blt(0,0,bitmap,Rect.new(0,0,60,80))
    @point_text.bitmap.blt(60,0,bitmap,Rect.new(350,0,60,80))
    @point_text.bitmap.draw_text(0,8,120,30,"总成就点",1)
    @point_text.x=30
    @point_text.y=40
    str=[]
    b=@point
    while b>0
      str.push(b%10)
      b=b/10
    end
    x=str.size*8.5
    for j in str
      x-=17
      x+=1 if str.size>=3
      @point_text.bitmap.blt(60+x,42,bitmap,Rect.new(15+j*17,258,17,24))
    end
    
    
    id=$merit[301][@mindex1]+@mindex1*100+1
    @msprite=[]
    for i in 0...5
      @msprite[i]=Sprite.new
      @msprite[i].bitmap=bitmap
      if $merit[id+i][0]
        @msprite[i].src_rect=Rect.new(0,0,410,80)
      else
        @msprite[i].src_rect=Rect.new(0,80,410,80)
      end
      @msprite[i].ox=205
      @msprite[i].x=400
      @msprite[i].y=80+i*100
    end
    @mtext=[]
    for i in 0...5
      @mtext[i]=Sprite.new
      @mtext[i].bitmap=Bitmap.new(410,80)
    #  @mtext[i].bitmap.font.name="黑体"
      @mtext[i].ox=205
      next if text[id+i]==nil
      @mtext[i].bitmap.font.size=18
      @mtext[i].bitmap.draw_text(60,0,300,40,text[id+i][2],1)
      @mtext[i].bitmap.font.size=14
      draw_merit_back(bitmap,text,id,i)
      @mtext[i].x=400
      @mtext[i].y=80+i*100
    end
    @mkind=[] 
    for i in 0...4
      @mkind[i]=Sprite.new
      @mkind[i].bitmap=RPG::Cache.title("title")
      @mkind[i].src_rect=Rect.new(16,506,198,45)
      @mkind[i].x=400
      @mkind[i].y=60
      @mkind[i].ox=99
      @mkind[i].oy=40
      @mkind[i].zoom_x=0.8
      @mkind[i].zoom_y=@mkind[i].zoom_x
    end
    wide=@mindex1*150
    high=@mindex2*100
    save=high
    save2=wide
    loop do
      normal_update
      if Input.trigger?(Input::B)
        @point_text.dispose
        for i in 0...4
          @mkind[i].dispose
        end
        for i in 0...5
          @msprite[i].dispose
          @mtext[i].dispose
        end
        for i in 0...3
          @choice[i].visible=true
        end
        for i in 0...15
          normal_update
          @sprop1-=17
          @sprop2-=17
        end
        @command_window1.active=true
        return
      end
      if Input.trigger?(Input::UP)
        @mindex2-=1 if @mindex2>0
        save_merit_index
      end
      if Input.trigger?(Input::DOWN)
        @mindex2+=1 if text[@mindex1%3*100+@mindex2+5]!=nil
        save_merit_index
      end
      if Input.trigger?(Input::LEFT)
        @mindex1-=1
        @mindex2=$merit[301][@mindex1%3]
        save=-1
        high=high.to_i%100+@mindex2*100
        save_merit_index
      end
      if Input.trigger?(Input::RIGHT)
        @mindex1+=1
        @mindex2=$merit[301][@mindex1%3]
        save=-1
        high=high.to_i%100+@mindex2*100
        save_merit_index
      end
      if high.to_i<@mindex2*100
        high+=[(@mindex2*100-high)/10.0,1].max
      end
      if high.to_i>@mindex2*100
        high-=[(high-@mindex2*100)/10.0,1].max
      end
      if wide.to_i<@mindex1*150
        wide+=[(@mindex1*150-wide)/10.0,1].max
      end
      if wide.to_i>@mindex1*150
        wide-=[(wide-@mindex1*150)/10.0,1].max
      end
      j=high.to_i/100
      id=@mindex1%3*100+j+1
      for i in 0...5
        if save!=j && text[id+i]!=nil
          @mtext[i].bitmap.clear
          @mtext[i].bitmap.font.size=18
          @mtext[i].bitmap.draw_text(60,0,300,40,text[id+i][2],1)
          @mtext[i].bitmap.font.size=14
          draw_merit_back(bitmap,text,id,i)
          if $merit[id+i][0]
            @msprite[i].src_rect=Rect.new(0,0,410,80)
          else
            @msprite[i].src_rect=Rect.new(0,80,410,80)
          end
        end
        @msprite[i].y=80-(high.to_i)%100+i*100
        @mtext[i].y=80-(high.to_i)%100+i*100
        if i==0
          @msprite[i].opacity=[255-(80-@msprite[i].y)*4,0].max
          @mtext[i].opacity=@msprite[i].opacity
        end
        if i==4
          @msprite[i].opacity=[(480-@msprite[i].y)*4,255].min
          @mtext[i].opacity=@msprite[i].opacity
        end
        @mtext[i].x=400
      end
      save=high.to_i/100
      j=wide.to_i/150
      for i in 0...4
        @mkind[i].src_rect=Rect.new(16,506+(i+j-1)%3*60,198,45)
        @mkind[i].x=250-(wide.to_i)%150+i*150
        a=[(400-@mkind[i].x).abs,255].min
        @mkind[i].opacity=255-a
        @mkind[i].zoom_x=0.9-a/550.0
        @mkind[i].zoom_y=@mkind[i].zoom_x
      end
      save2=wide.to_i/100
    end
  end
  def save_merit_index
    $merit[301][@mindex1%3]=@mindex2
    $merit[301][3]=@mindex1%3
    save_data($merit, "Save/Merit.rxdata")
  end
  def draw_merit_back(bitmap,text,id,i)
    if @mindex1%3==1 || $merit[id+i][0]
      @mtext[i].bitmap.draw_text(60,30,300,40,text[id+i][3],1)
    else
      @mtext[i].bitmap.draw_text(60,30,300,40,"剧情与探索类成就请自己寻找发掘其中的秘密",1)
    end
    if $merit[id+i][0]
      @mtext[i].bitmap.blt(15,10,bitmap,Rect.new(text[id+i][0]*44,160,44,44))
      @mtext[i].bitmap.blt(351,10,bitmap,Rect.new(0,204,44,44))
      a=258
    else
      @mtext[i].bitmap.blt(15,10,bitmap,Rect.new(176+text[id+i][0]*44,160,44,44))
      @mtext[i].bitmap.blt(351,10,bitmap,Rect.new(44,204,44,44))
      a=288
    end
    str=[]
    b=text[id+i][1].abs
    while b>0
      str.push(b%10)
      b=b/10
    end
    x=str.size*8.5
    for j in str
      x-=17
      x+=1 if str.size>=3
      @mtext[i].bitmap.blt(351+22+x,22,bitmap,Rect.new(15+j*17,a,17,24))
    end
  end
end